<%-- 
    Document   : layout
    Created on : 15-nov.-2012, 13:37:49
    Author     : Anthares
--%>
<%@tag description="Site layout" pageEncoding="UTF-8"%>
<%@taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib uri="/WEB-INF/tlds/form.tld" prefix="form" %>

<%-- The list of normal or fragment attributes can be specified here: --%>
<%@attribute name="pageTitle" required="true" type="java.lang.String"%>
<%@attribute name="script" required="false" type="java.lang.String"%>
<%@attribute name="stylesheet" required="false" type="java.lang.String"%>
<fmt:setLocale value="${requestScope.locale}"/>
<fmt:setBundle basename="Languages.lang"/>
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>${pageTitle}</title>
        <link rel="stylesheet" type="text/css" href="<core:url value="/style/reset.css"/>"/>
        <link rel="stylesheet" type="text/css" href="<core:url value="/style/style.css"/>"/>
        <link rel="stylesheet" type="text/css" href="<core:url value="/style/validationEngine.jquery.css"/>"/>
        <core:forTokens var="item" items="${stylesheet}" delims=",">
            <link rel="stylesheet" type="text/css" href="<core:url value="/style/"/>${item}}"/>
        </core:forTokens>

        <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
        <script type="text/javascript" src="<core:url value="/js/jquery.validationEngine.js"/>"></script>
        <script type="text/javascript" src="<core:url value="/js/jquery.validationEngine-en.js"/>"></script>
        <script type="text/javascript" src="<core:url value="/js/jquery.masonry.js"/>"></script>
        <script type="text/javascript" src="<core:url value="/js/main.js"/>"></script>
        <core:forTokens var="item" items="${script}" delims=",">
            <script type="text/javascript" src="<core:url value="/script/"/>${item}"></script>
        </core:forTokens>
    </head>
    <body>
        <div id="header">
            <div id="header-logo"></div>
            <div id="header-welcome">
                <p><a href="<core:url value="/language?lang=en_US&pagename=${pagename}"/>">[EN]</a> <a href="<core:url value="/language?lang=fr_FR&pagename=${pagename}"/>">[FR]</a></p>
                <fmt:message key="layout.welcome"/>, 
                <core:if test="${pageContext.request.getSession(false)== null || pageContext.request.getSession(false).getAttribute('user')==null}">
                    guest ! <a id="login-link" href="#"><fmt:message key="layout.login"/></a> <a href="<core:url value="/register"/>"><fmt:message key="layout.register"/></a>
                    <form:login/>
                </core:if>
                <core:if test="${pageContext.request.getSession(false)!= null && pageContext.request.getSession(false).getAttribute('user')!=null}">
                    ${pageContext.request.getSession(false).getAttribute('user').prenom} ${pageContext.request.getSession(false).getAttribute('user').nom} ! <a href="<core:url value="/login/logout"/>"><fmt:message key="layout.logout"/></a>
                </core:if>
            </div>
            <div id="header-navigation">
                <ul class="menu">
                    <li><a href="<core:url value="/home"/>"><fmt:message key="menu.element.home"/></a>
                    <li><a href="<core:url value="/shop"/>"><fmt:message key="menu.element.shop"/></a></li>
                    <li class="basket"><a href="<core:url value="/basket"/>"><fmt:message key="menu.element.basket"/> (${pageContext.request.getSession(false)!= null ? pageContext.request.getSession(false).getAttribute('basket').size() :0})</a></li>
                </ul>
            </div>
        </div>
        <div id="content">
            <jsp:doBody/>
        </div>
    </body>
</html>